package com.myshoutui;

import java.io.InputStream;
import java.security.GeneralSecurityException;

import com.myshout.Client;
import com.myshout.android.commmon.Utils;
import com.myshout.rest.RestClient;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

public class MyShoutConsumerMain extends Activity {

	Button mSignupBtn;
	Button mLoginbtn;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.myshoutmain);
		intializeServerParameters();
		mSignupBtn = ((Button)findViewById(R.id.myshoutmain_signup));
				mLoginbtn = ((Button)findViewById(R.id.myshoutmain_login));
				mSignupBtn.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/fontscore.com_h_helveticacondensed-bold.ttf"));
				mLoginbtn.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/fontscore.com_h_helveticacondensed-bold.ttf"));
				mSignupBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				startActivity(new Intent(getApplicationContext(), MyShoutConsumerSignupActivity.class));
				overridePendingTransition(R.anim.slide_right, R.anim.slide_left);
				finish();

			}
		});
				mLoginbtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				startActivity(new Intent(getApplicationContext(), MyShoutConsumerLoginActivity.class));
				overridePendingTransition(R.anim.slide_right, R.anim.slide_left);
				finish();
		
			}
		});
	}
	private void intializeServerParameters() {
		   RestClient.setAuthorizationScheme(RestClient.AUTHENTICATION_METHOD.BASIC);
	        // RestClient.setAuthorizationScheme(RestClient.AUTHENTICATION_METHOD.DIGEST);

	        InputStream in;
	        if (Client.HOST.equals("go2myshout.com"))
	            in = getResources().openRawResource(R.raw.go2myshout);
	        else if (Client.HOST.equals("movingbites.com"))
	            in = getResources().openRawResource(R.raw.movingbites);
	        else
	            in = getResources().openRawResource(R.raw.movingbites);

	        try {
	            RestClient.createSslContext(in, "ez24get");
	        } catch (GeneralSecurityException e) {
	            Utils.showMessage(this, getString(R.string.could_not_initialize_secure_connection_to_server));
	            e.printStackTrace();
	            finish();
	        }		
	}

	

}
